//
//  CommentView.m
//  吃货·上海
//
//  Created by 濮亚军 on 15/11/30.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "CommentView.h"
@interface CommentView()<UITextViewDelegate>

//背景
@property(nonatomic, strong)UIView *bgView;

//提示输入评论
@property(nonatomic, strong)UIImageView *commentImageView;


@end
@implementation CommentView
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        CGFloat height = frame.size.height * 2 / 5;
        //背景
        self.bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, height)];
        //self.bgView.backgroundColor = [UIColor grayColor];
        [self addSubview:_bgView];
        
        //提示
        self.commentImageView = [[UIImageView alloc]initWithFrame:CGRectMake(40 * KWNum, 40 * KWNum, 40 * KWNum, 30)];
        self.commentImageView.layer.masksToBounds = YES;
        [self.commentImageView.layer setCornerRadius:8];
        self.commentImageView.image = [UIImage imageNamed:@"commenting"];
        [self.bgView addSubview:_commentImageView];
        
        //评论输入框
        CGFloat width = frame.size.width - 130 * KWNum;
        self.commentTV = [[UITextView alloc]initWithFrame:CGRectMake((40 + 45) * KWNum, 40 * KWNum, width, 150 * KWNum)];
        self.commentTV.backgroundColor = [UIColor whiteColor];
        self.commentTV.layer.masksToBounds = YES;
        [self.commentTV.layer setCornerRadius:8];
        self.commentTV.textAlignment = NSTextAlignmentLeft;
        self.commentTV.delegate = self;
        self.commentTV.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:_commentTV];
        
        //提交
        self.submitImageView = [[UIImageView alloc]initWithFrame:CGRectMake( (frame.size.width - 70 * KWNum) / 2, (40 + 150 + 10) * KWNum, 70 * KWNum, 40 * KWNum)];
        //self.submitImageView.backgroundColor = [UIColor redColor];
        self.submitImageView.image = [UIImage imageNamed:@"submit"];
        self.submitImageView.userInteractionEnabled = YES;
        self.submitImageView.layer.masksToBounds = YES;
        [self.submitImageView.layer setCornerRadius:8];
        [self.bgView addSubview:_submitImageView];
    }
    return self;
}




//回收键盘
-(BOOL)textViewShouldEndEditing:(UITextView *)textView
{
    [textView resignFirstResponder];
    return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.commentTV resignFirstResponder];
}

@end
